import asyncio
import file_catcher
import logging


logger = logging.getLogger('client')
logging.basicConfig(level=logging.DEBUG)
# logging.basicConfig(filename='kademlia.log', level=logging.DEBUG)

loop = asyncio.get_event_loop()
fc = file_catcher.FileCatcher(5)
# sslcontext.load_cert_chain(certfile="cert.pem", keyfile="key.pem")
fc.add('nodse.py', [('127.0.0.1', 8888), ('127.0.0.1', 8889)])
fc.add('client.py', [('127.0.0.1', 8888), ('127.0.0.1', 8889)])
# asyncio.sleep(1)
loop.run_forever()
# loop = asyncio.get_event_loop()
# message = json.dumps({'file': 'README.md', 'offset': 0, 'size': 20})
# coros = [loop.create_connection(lambda: EchoClientProtocol(message, loop),
#                               '127.0.0.1', 8888, ssl=sslcontext),
#          loop.create_connection(lambda: EchoClientProtocol(message, loop),
#                                 '127.0.0.1', 8889, ssl=sslcontext)
#          ]
# loop.run_until_complete(asyncio.wait(coros))
# loop.run_forever()
# loop.close()
